home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Printing / Save Print Record / SaveAPrintRecord.p < prev    next >
Encoding:
Text File  |  1994-02-24  |  1.7 KB  |  69 lines  |  [TEXT/PJMM]

  1. {    This file has been processed by The THINK Pascal Source Converter, v1.1.2.    }
  2.  
  3. {------------------------------------------------------------------------------}
  4.  
  5.  
  6. {$I-}
  7. program Sample;
  8.  
  9.  
  10. uses
  11.     Traps, PrintTraps;
  12.  
  13. procedure Initialize;
  14.  
  15.     var
  16.         ignoreError: OSErr;
  17.         ignoreResult: BOOLEAN;
  18.         ourPrintRecord: THPrint;
  19.         ourReply: StandardFileReply;
  20.         ourOSErr: OSErr;
  21.         ourResRefNum: integer;
  22.  
  23.  
  24.     begin
  25.         InitGraf(@thePort);
  26.         InitFonts;
  27.         InitWindows;
  28.         InitMenus;
  29.         TEInit;
  30.         InitDialogs(nil);
  31.         InitCursor;
  32.  
  33.         PrOpen;
  34.         ourPrintRecord := THPrint(NewHandle(SIZEOF(TPrint)));
  35.         PrintDefault(ourPrintRecord);
  36.         ignoreResult := PrStlDialog(ourPrintRecord);
  37.         ignoreResult := PrJobDialog(ourPrintRecord);
  38.  
  39.         StandardPutFile('Save print record file as', 'My Print Record', ourReply);
  40.         ourOSErr := noErr;
  41.         if ourReply.sfGood then  {Did the user accept a file to save as?}
  42.             begin
  43.                 if ourReply.sfReplacing then
  44.                     ourOSErr := FSpDelete(ourReply.sfFile);    { make sure this is gone before we start! }
  45.                 if ourOSErr = noErr then
  46.                     begin
  47.                         FSpCreateResFile(ourReply.sfFile, 'RSED', 'RSRC', ourReply.sfScript);
  48.                         ourResRefNum := FSpOpenResFile(ourReply.sfFile, fsWrPerm);
  49.                         AddResource(Handle(ourPrintRecord), 'YO!!', 128, 'Saved print record');
  50.                         CloseResFile(ourResRefNum);
  51.                     end
  52.                 else
  53.                     SysBeep(10);
  54.             end;
  55.     end;
  56.  
  57.  
  58. begin
  59.  
  60.         {1.01 - call to ForceEnvirons removed}
  61.         {If you have stack requirements that differ from the default,}
  62.         {      then you could use SetApplLimit to increase StackSpace at }
  63.         {      this point, before calling MaxApplZone.}
  64.  
  65.     MaxApplZone; {expand the heap so code segments load at the top}
  66.  
  67.     Initialize; {initialize the program}
  68.     ExitToShell;
  69. end.